package ec.edu.udla.fichamedica.server;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import ec.edu.udla.fichamedica.client.EntityService;
import ec.edu.udla.fichamedica.domain.Person;
import ec.edu.udla.fichamedica.server.controller.PersonManager;

public class EntityServiceImpl extends RemoteServiceServlet implements
    EntityService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public List<Person> getPersons(String requestUri) {
		
		PersonManager manager = new PersonManager();
		List<Person> persons = manager.getResults();
		
		List<Person> personsReturn = new ArrayList<Person>();
		
		if(persons!=null){
			for(Person o:persons)
			{
				personsReturn.add(o);
			}
		}
		
		return personsReturn;
	}

	@Override
	public Boolean createPerson(Person p) {
		
		PersonManager manager = new PersonManager();
		
		return manager.create(p);
	}

	@Override
	public Boolean deletePerson(Person p) {
		
		PersonManager manager = new PersonManager();
		return manager.remove(p);
	}

	@Override
	public Boolean updatePerson(Person p) {

		PersonManager manager = new PersonManager();
		return manager.update(p);
	}

 
}